package top.whysu.study.thinkinjava.chapter8.polymorphism.example4;
import static net.mindview.util.Print.print;
public class Composing {
    private Shared shared;
    private static long counter = 0;
    private final long id = counter++;
    public Composing(Shared shared) {
        print("creating " + this);
        this.shared = shared;
        this.shared.addRef();
    }
    protected void dispose() {
        print("disposing " + this);
        shared.dispose();
    }

    @Override
    public String toString() {
        return "composing " + id;
    }
}